package com.yan;

import com.yan.bean.Resume;
import com.yan.repository.ResumeRepository;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.Date;
import java.util.List;

/**
 * TODO
 *
 * @Author: 汪焰
 * @Date: 2021/5/28 20:30
 */
@SpringBootApplication
public class MongodbRepositoryMain {

    public static void main(String[] args) {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(MongodbRepositoryMain.class, args);
        ResumeRepository resumeRepository = applicationContext.getBean(ResumeRepository.class);
        save(resumeRepository);
        findAll(resumeRepository);
    }

    private static void save(ResumeRepository resumeRepository) {
        Resume resume = new Resume();
        resume.setName("2222222222222222222222222222222");
        resume.setExpectSalary(55555);
        resume.setCity("深圳");
        resume.setBirthday(new Date());
        resumeRepository.save(resume);
    }

    private static void findAll(ResumeRepository resumeRepository) {
        List<Resume> all = resumeRepository.findAll();
        for (Resume resume : all) {
            System.out.println("-------" + resume);
        }
    }


}
